﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using AbpZeroTemplate.Authorization;
using AbpZeroTemplate.Caching;
using AbpZeroTemplate.Caching.Dto;
using AbpZeroTemplate.Web.Controllers;
using AbpZeroTemplate.Web.Swagger;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace AbpZeroTemplate.Api.Admin.Controllers
{
    /// <summary>缓存
    /// </summary>
    [Area("Admin")]
    [Route("Admin/Caching/[action]")]
    [ApiName("Admin")]
    [RemoteService]
    [AbpMvcAuthorize(AppPermissions.Pages_Administration_Host_Maintenance)]
    public class CachingController : AbpZeroTemplateControllerBase
    {
        private readonly ICachingAppService _cachingAppService;
        /// <summary>
        /// </summary>
        public CachingController(ICachingAppService cachingAppService)
        {
            _cachingAppService = cachingAppService;
        }

        /// <summary>获取全部的缓存
        /// </summary>
        [HttpGet]
        public ListResultDto<CacheDto> GetAllCaches()
        {
            return _cachingAppService.GetAllCaches();
        }

        /// <summary>清除缓存
        /// </summary>
        [HttpPost]
        public async Task ClearCache([FromBody]EntityDto<string> input)
        {
            await _cachingAppService.ClearCache(input);
        }

        /// <summary>清除全部缓存
        /// </summary>
        [HttpPost]
        public async Task ClearAllCaches()
        {
            await _cachingAppService.ClearAllCaches();
        }



    }
}
